home *** CD-ROM | disk | FTP | other *** search
Wrap
using System; using System.Collections; using System.IO; using System.Web; using System.Web.Caching; using System.Web.UI.WebControls; using GBPVR.Public; using GBPVRSchedule; /// <summary> /// Summary description for CSSProgrammeTableLoad /// </summary> /// namespace gbweb.classes { public class CSSProgrammeTableLoad { private Channel channel; private string displayClass; private bool searchRecordings = false; private Cache pageCache = new Cache(); private Type pageType; private HttpCookie cookie; private string forcedScrollbar = string.Empty; private string CONTENTS = string.Empty; //Create the table arrays to hold any found programs functional information private ArrayList Status = new ArrayList(); private ArrayList AirDate = new ArrayList(); private ArrayList Channel = new ArrayList(); private ArrayList Description = new ArrayList(); //Create the table arrays to hold any found programs display formatting information private ArrayList divStatusArray = new ArrayList(); private ArrayList divAirDateArray = new ArrayList(); private ArrayList divChannelArray = new ArrayList(); private ArrayList divDescArray = new ArrayList(); public CSSProgrammeTableLoad() { } public string getForcedScrollBar() { return forcedScrollbar; } public string getContents() { return CONTENTS; } public void Dispose() { Status.Clear(); AirDate.Clear(); Channel.Clear(); Description.Clear(); divStatusArray.Clear(); divAirDateArray.Clear(); divChannelArray.Clear(); divDescArray.Clear(); } public ArrayList sortDisplay(ArrayList sortOrders, ArrayList programmesToSort, bool isSortingSchedule) { programmesToSort.Sort(new programmeComparer(sortOrders, isSortingSchedule)); return programmesToSort; } #region Page Load code for the TableView - ProcessTable //This is the main driver routine for loading the TableView public void processTable(Type pagetype, ArrayList sortOrders, Cache cache, HttpRequest Request, HttpServerUtility Server, ProgrammeDisplay2 displayProgramme, bool strmAllowed, Programme programme, ScheduledRecording scheduledRecording, bool finalize_table) { pageCache = cache; pageType = pagetype; Schedule scheduleHelper = Global.Schedule; if (!finalize_table) { //Default the quality string String quality = string.Empty; if (scheduledRecording != null) { //Set the quailit string to the appropriate value switch (scheduledRecording.getQualitySetting()) { case (int) Schedule.Quality.Low: quality = "Low"; break; case (int) Schedule.Quality.Medium: quality = "Medium"; break; case (int) Schedule.Quality.High: quality = "High"; break; case (int) Schedule.Quality.Custom1: quality = "Custom 1"; break; case (int) Schedule.Quality.Custom2: quality = "Custom 2"; break; case (int) Schedule.Quality.LiveTV: quality = "LiveTV"; break; default: quality = string.Empty; break; } } //Set the channel that is associated to this schedule if (scheduledRecording != null) { channel = scheduleHelper.GetChannelByOID(scheduledRecording.getChannelOID()); } else { channel = scheduleHelper.GetChannelByOID(programme.getChannelOID()); } //Description Load Routine. We use a table cell since it matched the old code and provides a convienent container for storing not //only the formated display but also the appropriate css class for the status of the programme. The formatted description is then added to the //Description array. displayClass = string.Empty; TableCell programmeCell = new TableCell(); displayProgramme.FillProgrammeDisplay(Server, programmeCell, programme, scheduledRecording, true); Description.Add(programmeCell.Text); displayClass = programmeCell.CssClass; //Status Load Routine. Set the appropirate value for the status of the schedule and then add it to the Status array. string status = string.Empty; string checkMe = "$"; if (pageType.Name == "Manage2") { if (scheduledRecording != null) { checkMe = "<input name=\"item" + scheduledRecording.getOID() + "\" type=\"checkbox\" value=\"" + scheduledRecording.getOID() + "\"> Delete Me$"; } } if (scheduledRecording != null) { switch (scheduledRecording.getRecordingStatus()) { case ScheduledRecording.STATUS_PENDING: //Pending status entries will always have 4 dimensions status = "pending$" + checkMe + quality + "$" + "\"" + pageType.Name + ".aspx?cancel=" + scheduledRecording.getOID() + "\"" + "$" + displayClass; Status.Add(status); break; case ScheduledRecording.STATUS_IN_PROGRESS: //In-Progress status entries will always have between 5 and 7 dimensions status = "in-progress$" + checkMe + quality + "$\"" + Download.GetDownloadUrl(false, false, scheduledRecording.getOID()) + "\"$\"" + Download.GetDownloadUrl(true, true, scheduledRecording.getOID()) + "\""; if (strmAllowed) { status += "$" + "\"public/Player2.aspx?rid=" + scheduledRecording.getOID() + "&type=mr" + "\" onclick=\"EditPop5(this.href,'Add1');return false;\""; } if (programme == null) { status += "$" + "\"" + pageType.Name + ".aspx?cancel=" + scheduledRecording.getOID() + "\""; } status += "$" + displayClass; Status.Add(status); break; case ScheduledRecording.STATUS_COMPLETED: //Available status entries will always have between 5 and 7 dimensions status = "available$" + checkMe + quality + "$\"" + Download.GetDownloadUrl(false, false, scheduledRecording.getOID()) + "\"$\"" + Download.GetDownloadUrl(true, true, scheduledRecording.getOID()) + "\""; if (strmAllowed) { status += "$" + "\"public/Player2.aspx?rid=" + scheduledRecording.getOID() + "&type=mr" + "\" onclick=\"EditPop5(this.href,'Add1');return false;\""; } if (programme == null) { status += "$" + "\"" + pageType.Name + ".aspx?cancel=" + scheduledRecording.getOID() + "\""; } status += "$" + displayClass; Status.Add(status); break; case ScheduledRecording.STATUS_COMPLETED_WITH_ERROR: //Completed with error status entries will always have 4 dimensions status = "completed-error$" + checkMe + quality + "$" + "\"" + pageType.Name + ".aspx?cancel=" + scheduledRecording.getOID() + "\"" + "$" + displayClass; Status.Add(status); break; case ScheduledRecording.STATUS_CONFLICT: //Conflict status entries will always have 4 dimensions status = "conflict$" + checkMe + quality + "$" + "\"" + pageType.Name + ".aspx?cancel=" + scheduledRecording.getOID() + "\"" + "$" + displayClass; Status.Add(status); break; case ScheduledRecording.STATUS_PLACE_HOLDER: //Reocurring status entries will always have 4 dimensions status = "reocurring$" + checkMe + quality + "$" + "\"" + pageType.Name + ".aspx?cancel=" + scheduledRecording.getOID() + "\"" + "$listingReocurring"; Status.Add(status); break; case ScheduledRecording.STATUS_DELETED: //Deleted status entries will always have 2 dimensions status = "deleted" + "$listingDeleted"; Status.Add(status); break; default: //Unknown status entries will always have 2 dimensions status = "unknown" + "$" + displayClass; Status.Add(status); break; } } //The program is not currently recorded so we want to give the user the option to record this programme else { //if (pageType.Name == "SearchResults2") //{ searchRecordings = true; status = "open" + "$" + "<input name=\"item" + programme.getOID() + "\" type=\"checkbox\" value=\"" + programme.getOID() + "\"> Record Me$" + displayClass; //} //else //{ // status = "<input name=\"item" + scheduledRecording.getOID() + "\" type=\"checkbox\" value=\"" + // scheduledRecording.getOID() + "\"> Delete Me$"; //} Status.Add(status); } //AirDate Load Routine. The date is pulled from the schedule and formatted appropriatly. It is then loaded to the AirDate array. string date = null; string time = null; string airdate = string.Empty; string days = string.Empty; if (scheduledRecording != null) { switch (scheduledRecording.getRecordingType()) { case ScheduledRecording.TYPE_RECORD_ONCE: date = scheduledRecording.getStartTime().ToLongDateString(); time = scheduledRecording.getStartTime().ToShortTimeString() + " - " + scheduledRecording.getEndTime().ToShortTimeString(); break; case ScheduledRecording.TYPE_RECORD_DAILY: date = "Daily"; time = scheduledRecording.getStartTime().ToShortTimeString() + " - " + scheduledRecording.getEndTime().ToShortTimeString(); break; case ScheduledRecording.TYPE_RECORD_WEEK_DAYS: date = "Week Days"; time = scheduledRecording.getStartTime().ToShortTimeString() + " - " + scheduledRecording.getEndTime().ToShortTimeString(); break; case ScheduledRecording.TYPE_RECORD_WEEKEND_DAYS: date = "Weekend Days"; time = scheduledRecording.getStartTime().ToShortTimeString() + " - " + scheduledRecording.getEndTime().ToShortTimeString(); break; case ScheduledRecording.TYPE_RECORD_WEEKLY: date = "Weekly: " + scheduledRecording.getStartTime().DayOfWeek; time = scheduledRecording.getStartTime().ToShortTimeString() + " - " + scheduledRecording.getEndTime().ToShortTimeString(); break; case ScheduledRecording.TYPE_RECORD_SEASON: date = "Season"; if (scheduledRecording.getStartTime().Year != 2001) time = scheduledRecording.getStartTime().ToShortTimeString() + " - " + scheduledRecording.getEndTime().ToShortTimeString(); { days = scheduleHelper.getSeasonDayString(scheduledRecording); } break; } } else { date = programme.getStartTime().ToLongDateString(); time = programme.getStartTime().ToShortTimeString() + " - " + programme.getEndTime().ToShortTimeString(); } airdate = "<div class=\"airDate\">" + date + "</div><br><div class=\"airTime\">" + time + "</div>"; if (days != string.Empty) { airdate += "<br><div class=\"airTime\">" + days + "</div>"; } AirDate.Add(airdate); //Channel Load Routine. Pull the channel, channel name and channel icon and format appropriatly. The result is then added to the Channel array. string channelname = string.Empty; if (channel != null) { string channelName = channel.getName(); if (channelName.StartsWith(channel.getChannelNumber().ToString())) // cosmetic stuff for my american friends { if (channelName != channel.getChannelNumber().ToString()) { channelName = channelName.Substring(channel.getChannelNumber().ToString().Length + 1); } else { channelName = ""; } } cookie = Request.Cookies["useChannelIcons"]; string UseChannelIcons = cookie != null ? cookie.Value : "chnlText"; if (UseChannelIcons != "chnlIcon") { channelname = "<div class=\"channelNum\">" + channel.getChannelNumber() + "</div><div class=\"channelName\">" + channelName; } else { channelname = "<div class=\"channelNum\"></div><div class=\"channelName\">"; } string channelIcon = GetChannelIcon(channel.getChannelNumber(), new string[] {channel.getName(), channelName}); if (channelIcon != null && (UseChannelIcons != "chnlText")) { channelname += "<div id=\"CHANNEL_ICON\"><img src=\"" + Download.GetDownloadUrl(false, true, Download.InternalFiles.ChannelIcon, Server.UrlEncode(channelIcon)) + "\" alt=\"\" width=\"67\" height=\"50\" hspace=\"0\" vspace=\"0\" border=\"1\" runat=\"server\"></div></div>"; } else { channelname += "</div>"; } Channel.Add(channelname); } else { channelname = "" + "<br>" + ""; Channel.Add(channelname); } } if (finalize_table) { //Set the value for the header fields that shows what the current sort column is and in what order it is sorted string hdrStatus = "<div class=\"headerRow\" style=\"width:15%\"><a href=\"" + pageType.Name + ".aspx?sort=status\"><span>Status</span></a>" + getSortDescription(sortOrders[0], "status") + "</div>"; string hdrStatus2 = "<div class=\"headerRow\" style=\"width:5%\"><input type=\"checkbox\" class=\"selectAll\" onclick=\"SelectAllCheckboxes(this);\"><span>All</span></div><div class=\"headerRow\" style=\"margin-left: 5%;width:10%\"><a href=\"" + pageType.Name + ".aspx?sort=status\"><span>Status</span></a>" + getSortDescription(sortOrders[0], "status") + "</div>"; string hdrAirDate = "<div class=\"headerRow\" style=\"margin-left: 15%; width:15%\"><a href=\"" + pageType.Name + ".aspx?sort=datetime\"><span>Air Date</span></a>" + getSortDescription(sortOrders[0], "datetime") + "</div>\n"; string hdrChannel = "<div class=\"headerRow\" style=\"margin-left: 30%; width:10%\"><a href=\"" + pageType.Name + ".aspx?sort=channel\">Channel</a>" + getSortDescription(sortOrders[0], "channel") + "</div>\n"; string hdrDesc = "<div class=\"headerRow\" style=\"margin-left: 40%; width:60%\"><a href=\"" + pageType.Name + ".aspx?sort=title\">Show</a>" + getSortDescription(sortOrders[0], "title") + "</div>\n"; //Div Load Routine. These calls take the functional results that are stored in the arrays and then load them to a new array that includes the //formatting for displaying on the page. After each call we remove the data stored in the functional array so we are not being a memory hog. if (searchRecordings) { fillDiv(Status, hdrStatus2, "status"); } else { fillDiv(Status, hdrStatus2, "status"); } Status.Clear(); fillDiv(AirDate, hdrAirDate, "airdate"); AirDate.Clear(); fillDiv(Channel, hdrChannel, "channel"); Channel.Clear(); fillDiv(Description, hdrDesc, "desc"); Description.Clear(); //Set the first time indicator to true so that we know that we are loading the header row and not detail rows. bool first_time = true; //Since all the arrays will have the same number of entries we can just use one of them as the itterator. We proccess each entry in the formatted //arrays and add the final row level formating for each entry. while (divStatusArray.Count > 0) { //Pull each entry from the formatted array. string status = (string) divStatusArray[0]; string airdate = (string) divAirDateArray[0]; string channelinfo = (string) divChannelArray[0]; string desc = (string) divDescArray[0]; //Since we know have the current array entry as a string we can remove it from memory to help reduce resources being used divStatusArray.Remove(status); divAirDateArray.Remove(airdate); divChannelArray.Remove(channelinfo); divDescArray.Remove(desc); //Check to see if this is the first time in the loop. If it is then we know we are working with the header row and set the line formatting accordingly. if (first_time) { forcedScrollbar += status + airdate + channelinfo + desc + "<br><br>"; first_time = false; } //If it is not the first time then we know we are on the detial lines. So we combine the seperate entries into one line and add the appropriate line formatting. else { CONTENTS += "<div class=\"listingRow\">\n"; CONTENTS += "<div class=\"listings\" style=\"width:15%\">\n" + status + "</div>\n" + "<div class=\"listings\" style=\"margin-left: 15%; width:15%\">\n" + airdate + "</div>\n" + "<div class=\"listings\" style=\"margin-left: 30%; width:10%\">\n" + channelinfo + "</div>\n" + "<div class=\"listings\" style=\"margin-left: 40%; width:60%\">\n" + desc + "</div>\n</div>\n"; } } } } //This routine pulls the data from an array loaded with the formatted functional information and applys the appropriate grouping formatting. private void fillDiv(ArrayList info, string hdr, string arraytype) { //Load the first item in the array with the header information switch (arraytype) { case "status": { divStatusArray.Add(hdr); } break; case "airdate": { divAirDateArray.Add(hdr); } break; case "channel": { divChannelArray.Add(hdr); } break; case "desc": { divDescArray.Add(hdr); } break; } //Iterate through the array that contains the formatted functional information while (info.Count > 0) { //Pull the current array item out and assign it to a string for processing string item = (string)info[0]; //Some of the array entries (depending on type of array being processed) may conatain and array of values. We need to seperate them out so that we //have individual units to work with. string[] items = item.Split(new char[] { '$' }, 7); //Now that we have the current array entry in a string we can remove the entry from the array to reduce resource usage. info.Remove(item); //Initialice a string value that is used to simplify the concatenation of status infromation for the recording. string single = string.Empty; //Process the current array item (now in the string object called item) based on what type of recording status was passed into the method switch (arraytype) { case "status": //Format the status portion of the display row with the current item being processed. //Since we are processing a status array we know we are dealing with an array entry that contained seperate entries and thus was //split into a new array object called items. Each item in items contains a piece of information for formatting the status area of the //display line. switch (items[0]) { case "pending": single = "<div class=\"" + items[items.Length - 1] + "\">Pending</div>\n" + items[1] + " <div class=\"quality\" title=\"Quality\">Quality: " + items[2] + "</div><br/>\n<div class=\"butCancel\" title=\"Cancel\"><a href=\"\" onclick=\"goCancel(" + items[3].Replace("\"", "'") + ");return false;\" class=\"cellItem\">Cancel</div></a>"; break; case "in-progress": single = "<div class=\"" + items[items.Length - 1] + "\">In-Progress</div>\n" + items[1] + " <div class=\"quality\" title=\"Quality\">Quality: " + items[2] + "</div><br/>\n<div class=\"butPlay\" title=\"Play\"><a href=" + items[3] + "class=\"cellItem\">Play</div></a>"; single += "<div class=\"butDownload\" title=\"Download\"><a href=" + items[4] + ">Download</div></a>\n"; if (items.Length == 8) { single += "<div class=\"butStream\" title=\"Stream\"><a href=" + items[5] + ">Stream</div></a>"; single += "<div class=\"butCancel\" title=\"Cancle\"><a href=" + items[6] + ">Cancel</div></a>"; } else if (items.Length == 7) { single += "<div class=\"butStream\" title=\"Stream\"><a href=" + items[5] + ">Stream</div></a>"; } break; case "available": single = "<div class=\"" + items[items.Length - 1] + "\">Available</div>\n" + items[1] + " <div class=\"quality\" title=\"Quality\">Quality: " + items[2] + "</div><br/>\n<div class=\"butPlay\" title=\"Play\"><a href=" + items[3] + "class=\"cellItem\">Play</div></a>"; single += "<div class=\"butDownload\" title=\"Download\"><a href=" + items[4] + ">Download</div></a>\n"; if (items.Length == 8) { single += "<div class=\"butStream\" title=\"Stream\"><a href=" + items[5] + ">Stream</div></a>"; single += "<div class=\"butCancel\" title=\"Cancle\"><a href=" + items[6] + ">Cancel</div></a>"; } else if (items.Length == 7) { single += "<div class=\"butStream\" title=\"Stream\"><a href=" + items[5] + ">Stream</div></a>"; } break; case "completed-error": single = "<div class=\"" + items[items.Length - 1] + "\">Failed</div>\n" + items[1] + " <div class=\"quality\" title=\"Quality\">Quality: " + items[2] + "</div><br/>\n<div class=\"butCancel\" title=\"Cancel\"><a href=\"\" onclick=\"goCancel(" + items[3].Replace("\"", "'") + ");return false;\" class=\"cellItem\"><span>Cancel</sapn></div></a>"; break; case "conflict": single = "<div class=\"" + items[items.Length - 1] + "\">Conflict</div>\n" + items[1] + " <div class=\"quality\" title=\"Quality\">Quality: " + items[2] + "</div><br/>\n<div class=\"butCancel\" title=\"Cancel\"><a href=\"\" onclick=\"goCancel(" + items[3].Replace("\"", "'") + ");return false;\" class=\"cellItem\"><span>Cancel</span></div></a>"; break; case "reocurring": single = "<div class=\"" + items[items.Length - 1] + "\">Reocurring</div>\n" + items[1] + " <div class=\"quality\" title=\"Quality\">Quality: " + items[2] + "</div><br/>\n<div class=\"butCancel\" title=\"Cancel\"><a href=\"\" onclick=\"goCancel(" + items[3].Replace("\"", "'") + ");return false;\" class=\"cellItem\"><span>Cancel</span></div></a>"; break; case "deleted": single = "<div class=\"" + items[items.Length - 1] + "\">Deleted</div>"; break; case "unkown": single = "<div class=\"" + items[items.Length - 1] + "\">Unkown</div>"; break; case "open": single = "<div class=\"" + items[items.Length - 1] + "\">" + items[1] + "</div>"; break; } divStatusArray.Add(single); break; case "airdate": //Format the airdate portion of the display row with the current item being processed. { divAirDateArray.Add("<div class=\"cellItem\">" + item + "</div><br/><br/>"); } break; case "channel": //Format the channel portion of the display row with the current item being processed. { divChannelArray.Add("<div class=\"cellItem\">" + item + "</div>"); } break; case "desc": //Format the description portion of the display row with the current item being processed. { divDescArray.Add("<div class=\"cellItem\">" + item + "</div>"); } break; } } } #endregion #region Sorting processing logic //This checks the sort setting and if found it reverses the order from what it was set to static string getSortDescription(object selectedSort, string thisSort) { if (selectedSort.ToString() == thisSort) return " (asc)"; else if (selectedSort.ToString() == thisSort + " desc") return " (desc)"; else return string.Empty; } #endregion #region Channel Icon procssing logic private static string channelIconPath; private static string[] channelIconExtensions; public string GetChannelIcon(int channelNumber, string[] channelNames) { // Get the Channel Icon Directory if (channelIconPath == null) { lock (pageType) { if (channelIconPath == null) { channelIconPath = Path.Combine(Global.Settings.GetInstallDir(), @"media\ChannelLogos"); channelIconExtensions = Global.Settings.channelIconExtensions.Split(','); } } } Hashtable channelIconCache = (Hashtable)pageCache["channelIconCache"]; if (channelIconCache == null) { lock (pageType) { channelIconCache = (Hashtable)pageCache["channelIconCache"]; if (channelIconCache == null) { channelIconCache = new Hashtable(); pageCache.Add( "channelIconCache", channelIconCache, new CacheDependency(channelIconPath), DateTime.MaxValue, Cache.NoSlidingExpiration, CacheItemPriority.Normal, null); } } } if (channelIconCache.ContainsKey(channelNumber)) { return (string)channelIconCache[channelNumber]; } lock (channelIconCache) { if (channelIconCache.ContainsKey(channelNumber)) { return (string)channelIconCache[channelNumber]; } string channelIconFile = null; foreach (string channelName in channelNames) { foreach (string channelIconExtension in channelIconExtensions) { string cleanName = channelName; string channelNameWork = channelName; while (cleanName.Contains("/")) { if (channelNameWork.Contains("/")) { cleanName = channelNameWork.Remove(channelNameWork.IndexOf("/"), 1); channelNameWork = cleanName; } } string probeFile = cleanName + "." + channelIconExtension; if (File.Exists(Path.Combine(channelIconPath, probeFile))) { channelIconFile = probeFile; break; } } if (channelIconFile != null) break; } channelIconCache[channelNumber] = channelIconFile; return channelIconFile; } } #endregion #region Sorting processing logic class programmeComparer : IComparer { IList sortKeys; private IDictionary knownRecordings; private bool isSortingSchedule; public programmeComparer(IList SortKeys, bool sortType) { sortKeys = SortKeys; isSortingSchedule = sortType; // build up a list of the recording we already know about Schedule scheduleHelper = Global.Schedule; knownRecordings = scheduleHelper.LoadKnownRecordings(); } #region IComparer Members public int Compare(object x, object y) { for (int i = 0; i < sortKeys.Count; i++) { string key = sortKeys[i].ToString(); int order = 1; if (key.EndsWith(" desc")) { key = key.Substring(0, key.Length - 5); order = -1; } int result = getRecordingValue(x, key).CompareTo(getRecordingValue(y, key)); if (result != 0) return result * order; } return 0; } #endregion IComparable getRecordingValue(object obj, string key) { //Default the two types of objects that we could be dealing with for this sort ScheduledRecording scheduledRecording = new ScheduledRecording(); Schedule scheduleHelper = Global.Schedule; Programme pgm = new Programme(); if (isSortingSchedule) { scheduledRecording = (ScheduledRecording)obj; } else { pgm = (Programme)obj; } //Process the sorting for the appropriate object type if (!isSortingSchedule) { switch (key) { case "status": { scheduledRecording = null; if (knownRecordings.Contains(pgm.getOID())) scheduledRecording = (ScheduledRecording)knownRecordings[pgm.getOID()]; if (scheduledRecording != null) { switch (scheduledRecording.getRecordingStatus()) { case ScheduledRecording.STATUS_PENDING: return "Pending"; case ScheduledRecording.STATUS_IN_PROGRESS: return "In Progress"; case ScheduledRecording.STATUS_COMPLETED: return "Available"; case ScheduledRecording.STATUS_COMPLETED_WITH_ERROR: return "Failed"; case ScheduledRecording.STATUS_CONFLICT: return "Conflict"; case ScheduledRecording.STATUS_PLACE_HOLDER: return "Reoccurring"; case ScheduledRecording.STATUS_DELETED: return "Deleted"; default: return " "; } } else { return " "; } } case "datetime": { scheduledRecording = null; if (knownRecordings.Contains(pgm.getOID())) scheduledRecording = (ScheduledRecording)knownRecordings[pgm.getOID()]; if (scheduledRecording != null) { switch (scheduledRecording.getRecordingType()) { case ScheduledRecording.TYPE_RECORD_ONCE: return scheduledRecording.getStartTime().Ticks; default: return scheduledRecording.getStartTime().TimeOfDay.Ticks; } } else { return pgm.getStartTime().Ticks; } } case "channel": { if (pgm != null) { Channel channel = scheduleHelper.GetChannelByOID(pgm.getChannelOID()); if (channel != null) { return channel.getChannelNumber(); } } return 0; } case "title": { scheduledRecording = null; if (knownRecordings.Contains(pgm.getOID())) scheduledRecording = (ScheduledRecording)knownRecordings[pgm.getOID()]; if (scheduledRecording != null) { switch (scheduledRecording.getRecordingType()) { case ScheduledRecording.TYPE_RECORD_ONCE: if (pgm.getSubTitle().Length > 0) { return pgm.getTitle() + ": " + pgm.getSubTitle(); } else { return pgm.getTitle(); } default: return scheduledRecording.getFileName(); } } else { if (pgm.getSubTitle().Length > 0) { return pgm.getTitle() + ": " + pgm.getSubTitle(); } else { return pgm.getTitle(); } } } default: return string.Empty; } } else { switch (key) { case "status": { switch (scheduledRecording.getRecordingStatus()) { case ScheduledRecording.STATUS_PENDING: return "Pending"; case ScheduledRecording.STATUS_IN_PROGRESS: return "In Progress"; case ScheduledRecording.STATUS_COMPLETED: return "Available"; case ScheduledRecording.STATUS_COMPLETED_WITH_ERROR: return "Failed"; case ScheduledRecording.STATUS_CONFLICT: return "Conflict"; case ScheduledRecording.STATUS_PLACE_HOLDER: return "Reoccurring"; case ScheduledRecording.STATUS_DELETED: return "Deleted"; default: return "NONE!!"; } } case "datetime": { switch (scheduledRecording.getRecordingType()) { case ScheduledRecording.TYPE_RECORD_ONCE: return scheduledRecording.getStartTime().Ticks; default: return scheduledRecording.getStartTime().TimeOfDay.Ticks; } } case "channel": { Channel channel = scheduleHelper.GetChannelByOID(pgm.getChannelOID()); if (channel != null) { return channel.getChannelNumber(); } return 0; } case "title": { Programme programme = scheduledRecording.getProgramme(); switch (scheduledRecording.getRecordingType()) { case ScheduledRecording.TYPE_RECORD_ONCE: if (programme == null) { return "Manual Recording"; } else { if (programme.getSubTitle().Length > 0) { return programme.getTitle() + ": " + programme.getSubTitle(); } else { return programme.getTitle(); } } default: return scheduledRecording.getFileName(); } } default: return string.Empty; } } } } #endregion } }